package cn.com.oidreams.aliyun.robot.entity;

import cn.com.oidreams.aliyun.robot.enums.DingTalkEnum;
import cn.com.oidreams.common.annotations.Required;
import lombok.Data;

/***
 ** @category 带链接的消息
 ** @author qing.yunhui
 ** @email: qingyh@glodon.com
 ** @createTime: 2021-11-24 15:42
 **/
@Data
public class LinkMsgRequest extends BaseRequest<LinkMsgRequest>{

    @Required(errorMsg = "link不能为空",remark="link",classParse = true)
    private Link link;

    public LinkMsgRequest(Link link,String secret) {
        super.setMsgtype(DingTalkEnum.MSG_TYPE.LINK.getCode());
        this.link = link;
        super.setTimestamp(System.currentTimeMillis());
        super.setSecret(secret);
    }
    public LinkMsgRequest(){super();}

    @Data
    public static class Link {
        @Required(errorMsg = "消息标题不能为空",remark="消息标题",classParse = false)
        private String title;
        @Required(errorMsg = "消息内容不能为空",remark="消息内容",classParse = false)
        private String text;
        @Required(errorMsg = "跳转的URL不能为空",remark="跳转的URL",classParse = false)
        private String messageUrl;
        // --------------- 非必填 ---------------
        private String picUrl;
        // --------------- 构建函数 ---------------
        public Link(String title, String text, String messageUrl, String picUrl) {
            this.title = title;
            this.text = text;
            this.messageUrl = messageUrl;
            this.picUrl = picUrl;
        }
        public Link(String title, String text, String messageUrl){
            this(title,text,messageUrl,null);
        }
    }

}
